﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Ultility;
using System.Data;
using System.Data.SqlClient;
namespace Entity
{
    public partial class Entity_Room : Component
    {
        DBAccess _access = new DBAccess();
        public Entity_Room()
        {
            InitializeComponent();
        }

        public Entity_Room(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }
        public DataSet _ListRoomType()
        {
            return _access._ExcuteQuery("sp_ListAll_RoomType", null);
        }

        public bool _AddRoomType(string maPhong, string tenPhong, string giaPhong, string mieuta)
        {
            SqlParameter[] para = { new SqlParameter("@id",SqlDbType.NVarChar),
                                    new SqlParameter("@type",SqlDbType.NVarChar),
                                    new SqlParameter("@cost",SqlDbType.Float),
                                    new SqlParameter("@descr",SqlDbType.NVarChar),
                                    };

            para[0].Value =  maPhong;
            para[1].Value = tenPhong;
            para[2].Value = giaPhong;
            para[3].Value = mieuta;

            return _access._ExcuteNonQuery("sp_insert_RoomType", para);
        }
        public bool _delete_roomType(string maPhong)
        {
            SqlParameter[] para = { new SqlParameter("@id", SqlDbType.NVarChar) };
            para[0].Value = maPhong;
            return _access._ExcuteNonQuery("sp_delete_RoomType", para);
        }
        public bool _addRoom(string RoomID,string RoomTypeID,string RoomName,int NumberCustomer,bool TinhTrang,string Note)
        {
            SqlParameter[] para = { new SqlParameter("@id",SqlDbType.NVarChar),
                                    new SqlParameter("@roomtypeID",SqlDbType.NVarChar),
                                    new SqlParameter("@name",SqlDbType.NVarChar),
                                    new SqlParameter("@num",SqlDbType.Int),
                                    new SqlParameter("@tinhtrang",SqlDbType.Bit),
                                    new SqlParameter("@Note",SqlDbType.NVarChar),
                                    };
            para[0].Value = RoomID;
            para[1].Value = RoomTypeID;
            para[2].Value = RoomName;
            para[3].Value = NumberCustomer;
            para[4].Value = TinhTrang;
            para[5].Value = Note;
            return _access._ExcuteNonQuery("sp_insert_room", para);
        }

        public DataSet _ListAllRoom()
        {
            return _access._ExcuteQuery("sp_SelectAll_Room", null);
        }

        public bool _Update_Room(string RoomID, string RoomTypeID, string RoomName, int NumberCustomer, bool TinhTrang, string Note)
        {
            SqlParameter[] para = { new SqlParameter("@id",SqlDbType.NVarChar),
                                    new SqlParameter("@roomtypeID",SqlDbType.NVarChar),
                                    new SqlParameter("@name",SqlDbType.NVarChar),
                                    new SqlParameter("@num",SqlDbType.Int),
                                    new SqlParameter("@tinhtrang",SqlDbType.Bit),
                                    new SqlParameter("@Note",SqlDbType.NVarChar),
                                    };
            para[0].Value = RoomID;
            para[1].Value = RoomTypeID;
            para[2].Value = RoomName;
            para[3].Value = NumberCustomer;
            para[4].Value = TinhTrang;
            para[5].Value = Note;
            return _access._ExcuteNonQuery("sp_Update_room", para);
        }

        public bool _Delete_room(string id)
        {
            SqlParameter[] para = { new SqlParameter("@id", SqlDbType.NVarChar) };
            para[0].Value=id;

            return _access._ExcuteNonQuery("sp_delete_room",para);       
        }

        public bool _Update_roomtype(string maPhong, string tenPhong, string giaPhong, string mieuta)
        {
            SqlParameter[] para = { new SqlParameter("@id",SqlDbType.NVarChar),
                                    new SqlParameter("@type",SqlDbType.NVarChar),
                                    new SqlParameter("@cost",SqlDbType.Float),
                                    new SqlParameter("@descr",SqlDbType.NVarChar),
                                    };

            para[0].Value = maPhong;
            para[1].Value = tenPhong;
            para[2].Value = giaPhong;
            para[3].Value = mieuta;
            return _access._ExcuteNonQuery("sp_Update_Roomtype", para);
        }

        public DataSet _RoomStatus(int ngay, int thang, int nam)
        {
            SqlParameter[] para = { new SqlParameter("@day",SqlDbType.Int),
                                    new SqlParameter("@month",SqlDbType.Int),
                                    new SqlParameter("@year",SqlDbType.Int),
                                  };
            para[0].Value = ngay;
            para[1].Value = thang;
            para[2].Value = nam;
            return _access._ExcuteQuery("sp_ThongKeTungPhong", para);
        }

        public DataSet _thongkeRoom(string id)
        {
            SqlParameter[] para = { new SqlParameter("@id",SqlDbType.Char),
                                  };
            para[0].Value = id;
            return _access._ExcuteQuery("sp_TK_theoLoaiPhong", para);
        }

        public DataSet _TrangthaiPhong(string ngayDat, string ngayTra)
        {
            SqlParameter[] para = { new SqlParameter("@ngayDat",SqlDbType.DateTime),
                                    new SqlParameter("@ngayTra",SqlDbType.DateTime),
                                  };
            para[0].Value = ngayDat;
            para[1].Value = ngayTra;
            return _access._ExcuteQuery("sp_Room_status", para);
        }
    }
}
